home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.mactech.com 2010
/
ftp.mactech.com.tar
/
ftp.mactech.com
/
machack
/
Hacks97
/
WarriorsProgress.sit
/
Warrior’s Progress
/
source code
/
Source
/
Libraries
/
Integers
/
Range.cp
< prev
next >
Wrap
Text File
|
1997-06-28
|
2KB
|
78 lines
// Range.cp
#ifndef Range_h
#include "Range.h"
#endif
#ifndef MinMax_h
#include "MinMax.h"
#endif
template < class Value >
void Range<Value>::operator&=( const RangeType& r )
{
start = Max( start, r.start );
end = Min( end, r.end );
}
template < class Value >
void Range<Value>::operator|=( const RangeType& r )
{
start = Min( start, r.start );
end = Max( end, r.end );
}
template < class Value >
Range<Value> Range<Value>::operator&( const RangeType& r ) const
{
RangeType result( *this );
result &= r;
return result;
}
template < class Value >
Range<Value> Range<Value>::operator|( const RangeType& r ) const
{
RangeType result( *this );
result |= r;
return result;
}
template < class Value >
void Range<Value>::ExtendToContain( Value v )
{
Assert( Value( v+1 ) > v );
start = Min( start, v );
end = Max( end, Value( v+1 ) );
}
template < class Value >
void Range<Value>::ExtendToWeaklyContain( Value v )
{
start = Min( start, v );
end = Max( end, v );
}
template < class Value >
void Range<Value>::ExtendToStrictlyContain( Value v )
{
Assert( Value( v+1 ) > v );
Assert( Value( v-1 ) < v );
start = Min( start, Value( v-1 ) );
end = Max( end, Value( v+1 ) );
}
template < class Value >
void Range<Value>::ExtendToReverseContain( Value v )
{
Assert( Value( v-1 ) < v );
start = Min( start, Value( v-1 ) );
end = Max( end, v );
}
template class Range<int8>;
template class Range<uint8>;
template class Range<int16>;
template class Range<uint16>;
template class Range<int32>;
template class Range<uint32>;